home *** CD-ROM | disk | FTP | other *** search
/ Champak 66 / Vol 66.iso / games / bob_espo.swf / scripts / __Packages / MiniGames / BTW / BTWSpongeBob.as < prev    next >
Encoding:
Text File  |  2013-04-24  |  1.5 KB  |  48 lines

  1. class MiniGames.BTW.BTWSpongeBob extends State
  2. {
  3.    var oParent;
  4.    var oCurrentAim;
  5.    var sState;
  6.    var mcRef;
  7.    static var sSTATE_IDLE = "Idle";
  8.    static var sSTATE_THROW_BALL = "ThrowBall";
  9.    static var nBALL_THROWED_FRAME = 7;
  10.    function BTWSpongeBob(_mcRef, _oParent)
  11.    {
  12.       super(_mcRef);
  13.       this.setState(MiniGames.BTW.BTWSpongeBob.sSTATE_IDLE);
  14.       this.oParent = _oParent;
  15.       this.oCurrentAim = null;
  16.    }
  17.    function throwABall(_oCurrentAim)
  18.    {
  19.       if(this.sState == MiniGames.BTW.BTWSpongeBob.sSTATE_IDLE)
  20.       {
  21.          this.oCurrentAim = _oCurrentAim;
  22.          this.setState(MiniGames.BTW.BTWSpongeBob.sSTATE_THROW_BALL);
  23.          Controller.getRef().getSounds().playRandomSound(CTRLGame.nNB_THROW_SOUNDS,"IceBall_Throwed",Controller.nSFX_VOLUME);
  24.       }
  25.    }
  26.    function Idle()
  27.    {
  28.    }
  29.    function ThrowBall()
  30.    {
  31.       if(this.stateFinished())
  32.       {
  33.          this.setState(MiniGames.BTW.BTWSpongeBob.sSTATE_IDLE);
  34.       }
  35.       else if(this.mcRef.mcState._currentframe == MiniGames.BTW.BTWSpongeBob.nBALL_THROWED_FRAME)
  36.       {
  37.          var _loc2_ = new Object();
  38.          _loc2_.x = 0;
  39.          _loc2_.y = 0;
  40.          _loc2_.x = this.mcRef.mcState.mcBall._x;
  41.          _loc2_.y = this.mcRef.mcState.mcBall._y;
  42.          this.mcRef.mcState.localToGlobal(_loc2_);
  43.          this.mcRef._parent.globalToLocal(_loc2_);
  44.          this.oParent.createBall(this.oCurrentAim,_loc2_.x,_loc2_.y);
  45.       }
  46.    }
  47. }
  48.